﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;
using DevExpress.Web.Data;
using DevExpress.Web.ASPxFormLayout;
using DevExpress.Web.ASPxEditors;

namespace QLHieuThuocFull
{
    public partial class QuanLyNhanVien : System.Web.UI.Page
    {
        OrderedDictionary newValues;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                grid.StartEdit(2);
        }

        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            this.newValues = e.NewValues;
            PopulateNewValues();
        }
        private void PopulateNewValues()
        {
            ASPxFormLayout formLayout = (ASPxFormLayout)grid.FindEditFormTemplateControl("formLayout");
            formLayout.ForEach(ProcessItem);
        }
        private void ProcessItem(LayoutItemBase item)
        {
            LayoutItem layoutItem = item as LayoutItem;
            if (layoutItem != null)
            {
                ASPxEditBase editBase = layoutItem.GetNestedControl() as ASPxEditBase;
                if (editBase != null)
                    this.newValues[layoutItem.FieldName] = editBase.Value;
            }
        }

        protected void grid_RowInserting(object sender, ASPxDataInsertingEventArgs e)
        {
            this.newValues = e.NewValues;
            PopulateNewValues();
        }
    }
}